% ran = rand(2,2)
% a = 1 
% b = 2
% if a > b && b == 2
%     c = 3
% else
%     c = 5
% end

shadeIn = 0.25
lxPre = 687
lxNow = 987 
if shadeIn == 0
    if lxPre < 2000 & lxNow < 2000
        ran1 = rand(1);
        if ran1 < 0.95
            shadeOut = 0
        else
            ran2 = rand(1)
            if ran2 < 0.0167
                shadeOut = 0.5
            else
                ran3 = rand(1)
                if ran3 < 0.0167
                    shadeOut = 0.75
                else
                    ran4 = rand(1)
                    if ran4 < 0.0083
                        shadeOut = 0.25
                    else
                        rann = rand(1)
                        if rann < 0.0083
                            shadeOut = 1
                        else
                            shadeOut = 0
                        end
                    end
                end
            end
        end
    elseif lxPre < 2000 & lxNow >=2000
        ran5 = rand(1)
        if ran5 < 0.4881
            shadeOut = 1
        else
            ran6 = rand(1)
            if ran6 < 0.3452
                shadeOut = 0
            else
                ran7 = rand(1)
                if ran7 < 0.1071
                    shadeOut = 0.75
                else
                    rann = rand(1)
                    if rann < 0.0357
                        shadeOut = 0.5
                    else
                        shadeOut = 1
                    end
                end
            end
        end
    elseif lxPre >= 2000 & lxNow >= 2000
        ran8 = rand(1)
        if ran8 < 0.4688
            shadeOut = 0
        else
            ran9 = rand(1)
            if ran9 < 0.3438
                shadeOut = 1
            else 
                ran10 = rand(1)
                if ran10 < 0.125
                    shadeOut = 0.75
                else
                    rann = rand(1)
                    if rann < 0.0625
                        shadeOut = 0.5
                    else
                        shadeOut = 0
                    end
                end
            end
        end
    elseif lxPre >= 2000 & lxNow < 2000
        shadeOut = 0
    end
elseif shadeIn == 0.25
        if lxPre < 2000 & lxNow < 2000
            ran1 = rand(1)
            if ran1 < 0.9427
                shadeOut = 0.25
            else
                ran2 = rand(1)
                if ran2 < 0.0191
                    shadeOut = 0
                else
                    ran3 = rand(1)
                    if ran3 < 0.0191
                        shadeOut = 0.75
                    else
                        ran4 = rand(1)
                        if ran4 < 0.0127
                            shadeOut = 0.5
                        else
                            rann = rand(1)
                            if rann < 0.0064
                                shadeOut = 1
                            else
                                shadeOut = 0.25
                            end
                        end
                    end
                end
            end
        elseif lxPre < 2000 & lxNow >= 2000
            ran5 = rand(1)
            if ran5 < 0.5827
                shadeOut = 0.25
            else
                ran6 = rand(1)
                if ran6 < 0.3071
                    shadeOut = 1
                else
                    ran7 = rand(1)
                    if ran7 < 0.0945
                        shadeOut = 0.75
                    else
                        rann = rand(1)
                        if rann < 0.0157
                            shadeOut = 0.5
                        else
                            shadeOut = 0.25
                        end
                    end
                end
            end
        elseif lxPre >= 2000 & lxNow >= 2000
            ran8 = rand(1)
            if ran8 < 0.4823
                shadeOut = 0.25
            else
                ran9 = rand(1)
                if ran9 < 0.3688
                    shadeOut = 1
                else
                    ran10 = rand(1)
                    if ran10 < 0.1064
                        shadeOut = 0.75
                    else
                        rann = rand(1)
                        if rann < 0.0426
                            shadeOut = 0.5
                        else
                            shadeOut = 0.25
                        end
                    end
                end
            end
        elseif lxPre >= 2000 & lxNow < 2000
            shadeOut = 0.25
        end
elseif shadeIn == 0.5
    if lxPre < 2000 & lxNow < 2000
        ran1 = rand(1)
        if ran1 < 0.98
            shadeOut = 0.5
        else
            ran2 = rand(1)
            if ran2 < 0.02
                shadeOut = 0
            else
                ran3 = rand(1)
                if ran3 < 0.0133
                    shadeOut = 0.75
                else
                    ran4 = rand(1)
                    if ran4 < 0.0067
                        shadeOut = 0.25
                    else
                        rann = rand(1)
                        if rann < 0.0067
                            shadeOut = 1
                        else
                            shadeOut = 0.5
                        end
                    end
                end
            end
        end
    elseif lxPre < 2000 & lxNow >= 2000
        ran5 = rand(1)
        if ran5 < 0.6473
            shadeOut = 0.5
        else
            ran6 = rand(1)
            if ran6 < 0.314
                shadeOut = 1
            else
                rann = rand(1)
                if rann < 0.0388
                    shadeOut = 0.75
                else
                    shadeOut = 0.5
                end
            end
        end
    elseif lxPre >= 2000 & lxNow >= 2000
        ran7 = rand(1)
        if ran7 < 0.7258
            shadeOut = 0.5
        else
            ran8 = rand(1)
            if ran8 < 0.2258
                shadeOut = 1
            else
                rann = rand(1)
                if rann < 0.0484
                    shadeOut = 0.75
                else
                    shadeOut = 0.5
                end
            end
        end
    elseif lxPre >= 2000 & lxNow < 2000
        ran9 = rand(1)
        if ran9 < 0.825
            shadeOut = 0.5
        else
            ran10 = rand(1)
            if ran10 < 0.1
                shadeOut = 0.25
            else
                rann = rand(1)
                if rann < 0.075
                    shadeOut = 0
                else
                    shadeOut = 0.5
                end
            end
        end
    end
elseif shadeIn == 0.75
    if lxPre < 2000 & lxNow < 2000
        ran1 = rand(1)
        if ran1 < 0.8786
            shadeOut = 0.75
        else
            ran2 = rand(1)
            if ran2 < 0.0462
                shadeOut = 0.5
            else
                ran3 = rand(1)
                if ran3 < 0.0347
                    shadeOut = 0.25
                else
                    ran4 = rand(1)
                    if ran4 < 0.0231
                        shadeOut = 0
                    else
                        rann = rand(1)
                        if rann < 0.0173
                            shadeOut = 1
                        else
                            shadeOut = 0.75
                        end
                    end
                end
            end
        end
    elseif lxPre < 2000 & lxNow >= 2000
        ran5 = rand(1)
        if ran5 < 0.646
            shadeOut = 0.75
        else
            ran6 = rand(1)
            if ran6 < 0.3292
                shadeOut = 1
            else
                rann = rand(1)
                if rann < 0.0186
                    shadeOut = 0.5
                else
                    shadeOut = 0.75
                end
            end
        end
    elseif lxPre >= 2000 & lxNow >= 2000
        ran7 = rand(1)
        if ran7 < 0.7325
            shadeOut = 0.75
        else
            ran8 = rand(1)
            if ran8 < 0.2634
                shadeOut = 1
            else
                rann = rand(1)
                if rann < 0.0041
                    shadeOut = 0.5
                else
                    shadeOut = 0.75
                end
            end
        end
    elseif lxPre >= 2000 & lxNow < 2000
        ran9 = rand(1)
        if ran9 < 0.7179
            shadeOut = 0.75
        else
            ran10 = rand(1)
            if ran10 < 0.1026
                shadeOut = 0.25
            else
                ran11 = rand(1)
                if ran11 < 0.1026
                    shadeOut = 0.5
                else
                    ran12 = rand(1)
                    if ran12 < 0.0513
                        shadeOut = 0
                    else
                        rann = rand(1)
                        if rann < 0.0256
                            shadeOut = 1
                        else
                            shadeOut = 0.75
                        end
                    end
                end
            end
        end
    end
elseif shadeIn == 1
    if lxPre < 2000 & lxNow < 2000
        ran1 = rand(1)
        if ran1 < 0.7219
            shadeOut = 1
        else
            ran2 = rand(1)
            if ran2 < 0.1006
                shadeOut = 0.25
            else
                ran3 = rand(1)
                if ran3 < 0.1006
                    shadeOut = 0.5
                else
                    ran4 = rand(1)
                    if ran4 < 0.0296
                        shadeOut = 0.75
                    else
                        rann = rand(1)
                        if rann < 0.0237
                            shadeOut = 0
                        else
                            shadeOut = 1
                        end
                    end
                end
            end
        end
    elseif lxPre < 2000 & lxNow >=2000
        ran5 = rand(1)
        if ran5 < 0.9565
            shadeOut = 1
        else
            rann = rand(1)
            if rann < 0.0435
                shadeOut = 0.75
            else
                shadeOut = 1 
            end
        end
    elseif lxPre >= 2000 & lxNow >= 2000
        ran6 = rand(1)
        if ran6 < 0.9875
            shadeOut = 1
        else
            rann = rand(1)
            if rann < 0.0125
                shadeOut = 0.75
            else
                shadeOut = 1
            end
        end
    elseif lxPre >= 2000 & lxNow < 2000
        ran7 = rand(1)
        if ran7 < 0.8526
            shadeOut = 1 
        else
            ran8 = rand(1)
            if ran8 < 0.0641
                shadeOut = 0.75
            else
                ran9 = rand(1)
                if ran9 < 0.0577
                    shadeOut = 0.5
                else
                    ran10 = rand(1)
                    if ran10 < 0.0513
                        shadeOut = 0.25
                    else
                        rann = rand(1)
                        if rann < 0.0128
                            shadeOut = 0
                        else
                            shadeOut = 1
                        end
                    end
                end
            end
        end
    end
end

